class Stack:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return  self.items == []

    def push(self,item):
        self.items.append(item)

    def pop(self):
        return self.items.pop()

    def peek(self):
        return self.items[len(self.items)-1]

    def size(self):
        return len(self.items)

def infix_to_pre(infixexpr):
    s = Stack()
    l = []
    level = {}
    level["*"] = 3
    level["/"] = 3
    level["+"] = 2
    level["-"] = 2
    level["("] = 1
    blanced = True

    for i in infixexpr:

        if i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" or i in "0123456789":
            l.append(i)
        elif i == "(":
            s.push(i)
        elif i == "(":
            l.append(s.pop())
        elif i in "*?+_":
            if s.isEmpty():
                s.push(i)
            elif s.peek() == "(":
                s.push(i)
            elif level[s.peek()] > level[i]:
                l.append(s.pop())
                s.push(i)
            else:
                s.push(i)
        elif i == ")":
            if s.peek() == "(":
                blanced = False
            else:
                while True:
                    l.append(s.pop())
                    if s.peek() == "(":
                        s.pop()
                        break
    if s.size() != 0:
        index = 0
        while  s.size()>=1:

            if s.peek() == "(":
                blanced = False

            else:
                l.append(s.pop())

    if blanced:
        print(l)
    else:
        print("is not blanced")


print(infix_to_pre("A*B+C*D"))